package com.cicadamob.contact.api.service;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ValidUtil {
	public static final String PATTERN_MOBILE_PHONE = "(^(\\d{3,4}-)?\\d{7,8})$|(^((13[0-9])|(15[0-9])|(18[0-9]))\\d{8})$";

	/**
	 * 验证合法手机号码
	 * 
	 * @param number
	 *            输入手机号码
	 * @return
	 */
	public static boolean isValidMobilePhoneNumber(String number) {
		if (isNullOrEmpty(number)) {
			return false;
		}

		return number.matches(PATTERN_MOBILE_PHONE);
	}
	
	
	/**
	 * 判断指定的字符串是否为null或空字符串
	 * 
	 * @param str
	 * @return
	 */
	public static final boolean isNullOrEmpty(String str) {
		if ((str == null) || "".equals(str)) {
			return true;
		}

		return false;
	}
	
	
	
	
	
	/**
	 * 判断字母数字混合
	 * 
	 * @param str
	 * @return
	 */
	public static boolean isAllLetter(String str) {
		Pattern pattern = Pattern.compile("^[A-Za-z0-9]+$");
		Matcher isNum = pattern.matcher(str);
		if (!isNum.matches()) {
			return false;
		} else {
			return true;
		}
	}

}
